package com.bjpowerrnode.streamTest;

import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;

public class ICollect {
    public static void main(String[] args) {
        /**
         * Collectors 类实现了很多归约操作，例如将流转换成集合和聚合元素。Collectors 可用于返回列表或字符串：
         */
        List<String> stringList = Arrays.asList("abc","", "123","", "ijk", "456");
        List<String> collect = stringList.stream().filter(s -> !s.isEmpty()).collect(Collectors.toList());
        collect.forEach(System.out::println);

        String collect1 = stringList.stream().filter(s -> !s.isEmpty()).collect(Collectors.joining());
        System.out.println(collect1);
    }
}
